package com.wyw.base.comm;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wyw.core.config.XmlConfigListInitial;
import com.wyw.core.util.SpringContextUtil;
import com.wyw.core.util.WebCacheManager;


@Controller 
public class SysManager {
	protected final Log logger = LogFactory.getLog(getClass());
	
	@RequestMapping(value = "/sysManager/reloadCache.biz",method=RequestMethod.GET)//
	public @ResponseBody String reloadCache(){
		logger.info("【缓存刷新开始】");
		XmlConfigListInitial xmlConfigListInitial = (XmlConfigListInitial)SpringContextUtil.getBean("xmlConfigListInitial");
		boolean isLoadInit =  xmlConfigListInitial.getIsLoadInit();
		try{
			xmlConfigListInitial.setIsLoadInit(true);
			xmlConfigListInitial.afterPropertiesSet();
		}catch(Exception e){
			logger.error(e);
			logger.info("【缓存刷新失败】");
		}finally{
			xmlConfigListInitial.setIsLoadInit(isLoadInit);
		}
		logger.info("【缓存刷新结束】");
		return "ok";
	}
	
	@RequestMapping(value = "/sysManager/clearWebCache.biz",method=RequestMethod.GET)//
	public @ResponseBody String clearWebCache(){
		logger.info("【缓存webCache清除开始】");
		try{
			WebCacheManager.getCache().removeAll();
		}catch(Exception e){
			logger.error(e);
			logger.info("【缓存webCache清除】");
		}finally{
		}
		logger.info("【缓存webCache清除结束】");
		return "ok";
	}
	
	
	
}
